package com.ruoyi.order.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.ruoyi.order.domain.SysOrder;
import com.ruoyi.order.mapper.SysOrderMapper;
import com.ruoyi.order.service.ISysOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 ROP DATABASE IF EXISTS `ry-order`;

 CREATE DATABASE  `ry-order` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

 SET NAMES utf8mb4;
 SET FOREIGN_KEY_CHECKS = 0;

 USE `ry-order`;

 -- ----------------------------
 -- 订单信息表sys_order
 -- ----------------------------
 DROP TABLE IF EXISTS sys_order;
 CREATE TABLE sys_order
 (
 order_id      BIGINT(20)      NOT NULL AUTO_INCREMENT    COMMENT '订单ID',
 user_id       BIGINT(64)      NOT NULL                   COMMENT '用户编号',
 STATUS        CHAR(1)         NOT NULL                   COMMENT '状态（0交易成功 1交易失败）',
 order_no      VARCHAR(64)     DEFAULT NULL               COMMENT '订单流水',
 PRIMARY KEY (order_id)
 ) ENGINE=INNODB COMMENT = '订单信息表';
 * @author ruoyi
 */
@Service
public class SysOrderServiceImpl implements ISysOrderService 
{
    @Autowired
    private SysOrderMapper orderMapper;

    /**
     * 查询订单
     * 
     * @param orderId 订单编号
     * @return 订单信息
     */
    @Override
    @DS("order")
    public SysOrder selectSysOrderById(Long orderId)
    {
        return orderMapper.selectSysOrderById(orderId);
    }

    /**
     * 查询订单列表
     * 
     * @param sysOrder 订单信息
     * @return 订单列表
     */
    @Override
    @DS("order")
    public List<SysOrder> selectSysOrderList(SysOrder sysOrder)
    {
        List<SysOrder> sysOrders = orderMapper.selectSysOrderList(sysOrder);
        return sysOrders;
    }

    /**
     * 新增订单
     * 
     * @param sysOrder 订单
     * @return 结果
     */
    @Override
    @DS("order")
    public int insertSysOrder(SysOrder sysOrder)
    {
        int result = orderMapper.insertSysOrder(sysOrder);
        return result;
    }
}
